using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using MicroMsg.Plugin.QQInfo.Manager;
using MicroMsg.Storage;
using System;
using System.Collections.Generic;
namespace MicroMsg.Plugin.QQInfo.Scene
{
	public class QQInfoService
	{
		private const string TAG = "QQInfoService";
		public const int MIN_CLEAN_INTERVAL = 3600000;
		private const string TimeStampGroup = "dblLastGetQQGroupTimeStamp";
		private const string TimeStampFriend = "dblLastGetQQFriendTimeStamp";
		private static QQInfoService mInstance;
		public static QQInfoService getInstance()
		{
			if (QQInfoService.mInstance == null)
			{
				QQInfoService.mInstance = new QQInfoService();
			}
			return QQInfoService.mInstance;
		}
		public List<QGroup> GetQQGroupList(ref NetSceneQQInfo scene)
		{
			scene = new NetSceneQQInfo();
			List<QGroup> list = StorageMgr.qgroup.getList();
			double nowMilliseconds = Util.getNowMilliseconds();
			if (nowMilliseconds > ConfigMgr.getDouble("dblLastGetQQGroupTimeStamp", 0.0) + 3600000.0 || list == null || list.get_Count() == 0)
			{
				ConfigMgr.setDouble("dblLastGetQQGroupTimeStamp", nowMilliseconds);
				scene.doScene(NetSceneQQInfo.OPTYPE.OPTYPE_GROUP, 0u);
			}
			return list;
		}
		public List<QFriend> GetQQFriendList(uint groupID, int groupMemberNum, ref NetSceneQQInfo scene)
		{
			scene = new NetSceneQQInfo();
			List<QFriend> sortedQFriendList = QFriendMgr.getSortedQFriendList((int)groupID);
			double nowMilliseconds = Util.getNowMilliseconds();
			if (sortedQFriendList == null || sortedQFriendList.get_Count() == 0 || sortedQFriendList.get_Count() != groupMemberNum || nowMilliseconds > ConfigMgr.getDouble("dblLastGetQQFriendTimeStamp", 0.0) + 3600000.0)
			{
				ConfigMgr.setDouble("dblLastGetQQFriendTimeStamp", nowMilliseconds);
				scene.doScene(NetSceneQQInfo.OPTYPE.OPTYPE_FRIEND, groupID);
			}
			return sortedQFriendList;
		}
		public void ClearTimeStamp()
		{
			ConfigMgr.setDouble("dblLastGetQQFriendTimeStamp", 0.0);
		}
	}
}
